<template>
	<view>
		<view class="header status_bar" :class="scrrol == true ? 'scrrolHeader' : ''">
			<view class="back iconfont icon-xiangzuo1" @tap="backPage"></view>
			<view class="text" :class="scrrol == true ? 'scrrolHeader' : ''">分享</view>
		</view>	
		<view class="bg_box">
			<image class="bg01" :src="getImgSrc('/static/bg03.png')"  mode="scaleToFill"></image>
			<view class="bg_content">
				<view class="post">
					<image class="pt" :src="getImgSrc('/static/post.png')" mode="widthFix"></image>
					<image class="ewm" :src="share_img" mode="widthFix"></image>
				</view>
				<!-- <view class="post_menu" @tap="saveHeadImgFile">立即分享</view> -->
				<button class="post_menu" open-type="share">立即分享</button>
				
			</view>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				scrrol:false,
				info:'',
				share_img:'',
				uid:0,
			}
		},
		onLoad() {
			let that = this;
			that.loadData();
		},
		methods: {
			loadData() {
				let that = this;
				that.Net._get('auth/share_post', {}, res => {
					if (res.code == 200) {
						that.share_img = res.data.share_img;
						that.uid = res.data.uid;
					}
				});
			},
			backPage() {
				uni.navigateBack({});
			},
			gotopage(e) {
				let url = e.currentTarget.dataset.url;
				uni.navigateTo({
					url: url
				});
			},
			onShareAppMessage(res) {
				// 如果是直接分享按钮分享
				if (res.from === 'button') {
					// 处理分享参数
					const shareTicket = this.uid;
					// 使用shareTicket作为参数传递给后端，后端可以解析获取额外信息
					// 返回分享的内容
					return {
						title: '分享',
						path: `/pages/index/index?invite_id=${shareTicket}`,
						imageUrl: this.share_img // 分享卡片的图片，可选
					};
				}
			},
			saveHeadImgFile() {
				uni.downloadFile({ //下载
					url: this.share_img, // 图片下载地址
					success: res => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({ // 保存图片到系统相册。
								filePath: res.tempFilePath, // 图片文件路径
								success: function() {
									uni.showToast({
										title: '图片保存成功',
										icon: 'none',
									});
								},
								fail: function(e) {
									console.log(e);
									uni.showToast({
										title: '图片保存失败',
										icon: 'none',
									});
								},
							});
						}
					}
				});
			},
		},
		onPageScroll: function(Object) {
			//console.log(Object.scrollTop); //实时获取到滚动的值
			if (Object.scrollTop > 28) {
				this.scrrol = true;
				/* #ifdef APP-PLUS */
				/* #endif */
			} else if (Object.scrollTop < 28) {
				this.scrrol = false;
				/* #ifdef APP-PLUS */
				/* #endif */
			}
		},
		onReachBottom() {
			var that = this;
			that.page++;
		},
	}
</script>

<style>
	page{
		padding-bottom: 0 !important;
	}
	
	.header{
		background-color: transparent !important;
	}
	
	.header .text{
		background-color: transparent !important;
		color: #fff !important;
	}
	
	.scrrolHeader{
		background-color: #FF7701 !important;
	}
	
	.bg_box{
		width: 100%;
		position: relative;
	}
	
	.bg_box .bg01{
		width: 100%;
		height: 100vh;
	}
	
	.bg_box .bg_content{
		width: 92%;
		position: absolute;
		left: calc(50% - 46%);
		top: calc(13.5vw + var(--status-bar-height));
		z-index: 98;
	}
	
	.bg_box .bg_content .post{
		width: 100%;
		margin-top: 10vw;
		position: relative;
	}
	
	.bg_box .bg_content .post .pt{
		width: 100%;
	}
	
	.bg_box .bg_content .post .ewm{
		width: 24vw;
		position: absolute;
		right: 4vw;
		bottom: 7vw;
		z-index: 97;
	}
	
	.bg_box .bg_content .post_menu{
		width: 50vw;
		height: 15vw;
		margin: 10vw auto 0;
		border-radius: 15vw;
		font-size: 5vw;
		font-weight: bold;
		color: #fff;
		background: linear-gradient(to right, #FF7701, #FFA120);
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	
	
	
</style>
